<?php
/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
// Chat Server
// Project: molten-chat
// Developed by: Matthew Oltendorf
// Version: b2.1
// Updated on: June 04th, 2009
// Copyright (c) 2008-2009 Matthew Oltendorf
// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */

// PHP: Hypertext Preprocessor Document

/*
	Unfinished Items:
		1.
        2.
		3.
		4.
		5.
*/

/*
	Known Issues:
		1.	Does not work on load balanced server clusters; must be run on a single server. This is due to the shared memory cache.
		2.
		3.
		4.
		5.
*/

if (
	!defined ('molten_chat')
)
	{
		die ('Unauthorised Access.');
	}

/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
// Name: molten_chat_core
// Type: Singleton.
// Title: MoltX Chat Function Core Object.
// Description: All of these functions are for use by user-called functions, but should not be called by themselves.
// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
class molten_chat_core
	{
		/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
		// Name: __construct
		// Title: Class construction.
		// Variables: None.
		// Description: Disabled.
		// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
		private function __construct ()
			{
				// No further actions required.
				return false;
			}

		/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
		// Name: __destruct
		// Title: Class destruction.
		// Variables: None.
		// Description: Disabled.
		// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
		private function __destruct ()
			{
				// No further actions required.
				return false;
			}
		
		/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
		// Name: system
		// Title: System output.
		// Variables: $message
		//	1.	$message: The message to output.
		// Description: Outputs a system message to the chat history.
		// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
		protected static function system ($message)
			{
				return false;
			}
	}

/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
// Name: molten_chat_functions
// Type: Singleton.
// Title: MoltX Chat Function Object.
// Description: All of these functions can be called by users in chat rooms that have permission to do so.
// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
final class molten_chat_functions extends molten_chat_core
	{
		/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
		// Name: __construct
		// Title: Class construction.
		// Variables: None.
		// Description: Disabled.
		// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
		private function __construct ()
			{
				// No further actions required.
				return false;
			}
		
		/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
		// Name: __destruct
		// Title: Class destruction.
		// Variables: None.
		// Description: Disabled.
		// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
		private function __destruct ()
			{
				// No further actions required.
				return false;
			}
		
		/* --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- //
		// Name: foo
		// Title: Generic.
		// Variables: $user
		//	1.	$user: Does nothing.
		// Description: Outputs a random string.
		// --|-- ----- ----- ----- -----|----- ----- ----- ----- --|-- */
		private static function foo ($user)
			{
				$messages = array (
					'Foo!',
					'Freem!',
					'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
				);
				
				$random = mt_rand (0, (count ($messages) - 1));
				
				parent :: system ($messages [$random]);
				
				// No further actions required.
				return true;
			}
	}
?>